import sys

# 列表推导式(立即计算)
squares_list = [x * x for x in range(1000000)]

# 生成器表达式(惰性计算)
squares_gen = (x * x for x in range(1000000))

print(f"列表大小: {sys.getsizeof(squares_list)} bytes")
print(f"生成器大小: {sys.getsizeof(squares_gen)} bytes")

""" 结果:
列表大小: 8448728 bytes
生成器大小: 104 bytes
"""